﻿namespace IsToeplitz
{
    class Program
    {
        bool isToeplitz(int m, int n, int[][] input)
        {
            //int i = m, j = 0;
            int temp, x, y;
            for (int i = 0; i < m; i++)
            {
                temp = input[i][0];
                x = i;
                y = 0;
                while (x < m && y < n)
                {
                    if (input[x++][y++] != temp)
                        return false;
                }
            }
            for (int j = 0; j < n; j++)
            {
                temp = input[0][j];
                x = 0;
                y = j;
                while (x < m && y < n)
                {
                    if (input[x++][y++] != temp)
                        return false;
                }
            }
            return true;
        }


        static void Main(string[] args)
        {
            int[][] a = new int[3][];
            a[0] = new int[] { 1, 2, 3, 4 };
            a[1] = new int[] { 5, 1, 2, 3 };
            a[2] = new int[] { 9, 5, 1, 2 };

            Program program = new Program();
            Console.WriteLine(program.isToeplitz(3,4,a));
        }
    }
}
